package com.guanyu.u2cache.manage;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zhouyunjian
 * @date 2023/12/05 15:03
 **/
public class ListenerEventManag {
    /**
     * key-缓存事件名
     * value-缓存名
     */
    private final Map<String, String[]> cacheMap = new ConcurrentHashMap(16);
    private static final ListenerEventManag singleton = new ListenerEventManag();

    public static ListenerEventManag getSingleton() {
        return singleton;
    }

    /**
     * 建立绑定关系
     *
     * @param eventName
     * @param cacheNames
     */
    public void registerEvent(String eventName, String[] cacheNames) {
        this.cacheMap.put(eventName, cacheNames);
    }

    /**
     * 获取事件对应的缓存名列表
     *
     * @param eventName
     * @return
     */
    public String[] getCacheNames(String eventName) {
        return this.cacheMap.get(eventName);
    }
}
